import 'package:json_annotation/json_annotation.dart';

part 'char_record_res.g.dart';

@JsonSerializable(fieldRename: FieldRename.none)
class CharRecordRes {
  final int? code;
  final Data? data;
  final String? msg;

  const CharRecordRes({
    this.code,
    this.data,
    this.msg,
  });

  factory CharRecordRes.fromJson(Map<String, dynamic> json) =>
      _$CharRecordResFromJson(json);

  Map<String, dynamic> toJson() => _$CharRecordResToJson(this);

  CharRecordRes copyWith({
    int? code,
    Data? data,
    String? msg,
  }) {
    return CharRecordRes(
      code: code ?? this.code,
      data: data ?? this.data,
      msg: msg ?? this.msg,
    );
  }
}

@JsonSerializable(fieldRename: FieldRename.none)
class Data {
  final List<ChatMessage>? list;
  final int? total;

  const Data({
    this.list,
    this.total,
  });

  factory Data.fromJson(Map<String, dynamic> json) =>
      _$DataFromJson(json);

  Map<String, dynamic> toJson() => _$DataToJson(this);

  Data copyWith({
    List<ChatMessage>? list,
    int? total,
  }) {
    return Data(
      list: list ?? this.list,
      total: total ?? this.total,
    );
  }
}

@JsonSerializable(fieldRename: FieldRename.none)
class ChatMessage {
  final int? id;
  final int? cid;
  final int? senderId;
  final int? receiverId;
  final String? messageContent;
  final int? messageType;
  final int? createTime;

  const ChatMessage({
    this.id,
    this.cid,
    this.senderId,
    this.receiverId,
    this.messageContent,
    this.messageType,
    this.createTime,
  });

  factory ChatMessage.fromJson(Map<String, dynamic> json) =>
      _$ChatMessageFromJson(json);

  Map<String, dynamic> toJson() => _$ChatMessageToJson(this);

  ChatMessage copyWith({
    int? id,
    int? cid,
    int? senderId,
    int? receiverId,
    String? messageContent,
    int? messageType,
    int? createTime,
  }) {
    return ChatMessage(
      id: id ?? this.id,
      cid: cid ?? this.cid,
      senderId: senderId ?? this.senderId,
      receiverId: receiverId ?? this.receiverId,
      messageContent: messageContent ?? this.messageContent,
      messageType: messageType ?? this.messageType,
      createTime: createTime ?? this.createTime,
    );
  }
}
